/**
* Copyright (C) 2020 Xilinx, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#ifndef UTILS_H
#define UTILS_H
#include <sys/time.h>
inline int tvdiff(struct timeval* tv0, struct timeval* tv1) {
    return (tv1->tv_sec - tv0->tv_sec) * 1000000 + (tv1->tv_usec - tv0->tv_usec);
}
//--------------------------------------------------------------

#include <new>

#include <algorithm>
#include <cstdlib>
#include <iterator>
#include <vector>

template <typename T>

T* aligned_alloc(std::size_t num)

{
    void* ptr = nullptr;

    if (posix_memalign(&ptr, 4096, num * sizeof(T))) throw std::bad_alloc();

    return reinterpret_cast<T*>(ptr);
}
#endif
